package com.imooc.o2o.util;

import com.google.code.kaptcha.Constants;

import javax.servlet.http.HttpServletRequest;

/**
 * 判断验证码工具类
 * Created by Knight on 2018/7/3.
 */
public class CodeUtil {
    public static boolean checkVerifyCode(HttpServletRequest request){
        String verifyCodeExpected=(String) request.getSession().getAttribute(
                Constants.KAPTCHA_SESSION_KEY
        );
        String verifyCodeActual=HttpServiceRequestUtil.getString(request,"verifyCodeActual");
        if(verifyCodeActual==null||!verifyCodeExpected.equals(verifyCodeActual.toUpperCase())){
            return false;
        }else{
            return true;
        }
    }
}
